// import MyHome from '@/page/Home'
// import MyLogin from '@/page/Login'
// import MyRegister from '@/page/Register'
// import MySearch from '@/page/Search'
// import MyDetail from '@/page/Detail'
// import MyAddCartSuccess from '@/page/AddCartSuccess'
// import MyShopCart from '@/page/ShopCart'
// import MyTrade from '@/page/Trade'
// import MyPay from '@/page/Pay'
// import MyPaySuccess from '@/page/PaySuccess'
// import MyCenter from '@/page/Center'
// // 引入二级路由
// import MyOrder from '@/page/Center/MyOrder'
// import GroupOrder from '@/page/Center/GroupOrder'


export default [{
    path: '/',
    redirect: '/home'
},
{
    path: '/home',
    // 路由懒加载 加载对应组件 更加高效 都属于前台优化
    // 只有用户实际访问该对应路由才会执行加载该组件 否则不加载不执行(因为现在是函数)
    component: () => import('@/page/Home'),
    meta: { show: true },
},
{
    path: '/login',
    component: () => import('@/page/Login'),
    meta: { show: false },
},
{
    path: '/register',
    component: () => import('@/page/Register'),
    meta: { show: false },
},
{
    name: 'Search',
    path: '/search/:keyword?',
    component: () => import('@/page/Search'),
    meta: { show: true },
},
{
    name: 'Detail',
    path: '/detail/:skuid?',
    component: () => import('@/page/Detail'),
    meta: { show: true },
},
{
    name: 'AddCart',
    path: '/addcart/:skuNmb?',
    component: () => import('@/page/AddCartSuccess'),
    meta: { show: true },
},
{
    name: 'ShopCart',
    path: '/shopcart',
    component: () => import('@/page/ShopCart'),
    meta: { show: true },
},
{
    name: 'Trade',
    path: '/trade',
    component: () => import('@/page/Trade'),
    // 独享守卫
    beforeEnter: (to, from, next) => {
        // 只有从购物车页而来才可进入结算页
        if (from.path == '/shopcart') {
            next()
        } else {
            // 否则那来回哪去
            next(false)
        }
    },
    meta: { show: true },

},
{
    name: 'Pay',
    path: '/pay',
    component: () => import('@/page/Pay'),
    // 独享守卫
    beforeEnter: (to, from, next) => {
        // 只有从结算页而来才可进入支付页
        if (from.path == '/trade') {
            next()
        } else {
            // 否则那来回哪去
            next(false)
        }
    },
    meta: { show: true },
},
{
    name: 'PaySuccess',
    path: '/paysuccess',
    component: () => import('@/page/PaySuccess'),
    // 独享守卫
    beforeEnter: (to, from, next) => {
        // 只有从支付页而来才可进入支付成功页
        if (from.path == '/pay') {
            next()
        } else {
            // 否则那来回哪去
            next(false)
        }
    },
    meta: { show: true },
},
{
    name: 'Center',
    path: '/center',
    redirect: '/center/myorder',
    component: () => import('@/page/Center'),
    meta: { show: true },
    children: [{
        path: 'myorder',
        component: () => import('@/page/Center/MyOrder'),
    },
    {
        path: 'grouporder',
        component: () => import('@/page/Center/GroupOrder'),
    },

    ]
},
]
